<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>全部信息</title>
    <link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body bgcolor="#d3d4cc">


<script>
    (function fairyDustCursor() {

        var possibleColors = ["#ead0d1", "#eee5f8", "#8696a7"]
        var width = window.innerWidth;
        var height = window.innerHeight;
        var cursor = {x: width / 2, y: width / 2};
        var particles = [];

        function init() {
            bindEvents();
            loop();
        }

        // Bind events that are needed
        function bindEvents() {
            document.addEventListener('mousemove', onMouseMove);
            window.addEventListener('resize', onWindowResize);
        }

        function onWindowResize(e) {
            width = window.innerWidth;
            height = window.innerHeight;
        }

        function onMouseMove(e) {
            cursor.x = e.clientX;
            cursor.y = e.clientY;

            addParticle(cursor.x, cursor.y, possibleColors[Math.floor(Math.random() * possibleColors.length)]);
        }

        function addParticle(x, y, color) {
            var particle = new Particle();
            particle.init(x, y, color);
            particles.push(particle);
        }

        function updateParticles() {

            // Updated
            for (var i = 0; i < particles.length; i++) {
                particles[i].update();
            }

            // Remove dead particles
            for (var i = particles.length - 1; i >= 0; i--) {
                if (particles[i].lifeSpan < 0) {
                    particles[i].die();
                    particles.splice(i, 1);
                }
            }

        }

        function loop() {
            requestAnimationFrame(loop);
            updateParticles();
        }

        /**
         * Particles
         */

        function Particle() {

            this.character = "*";
            this.lifeSpan = 120; //ms
            this.initialStyles = {
                "position": "fixed",
                "display": "inline-block",
                "top": "0px",
                "left": "0px",
                "pointerEvents": "none",
                "touch-action": "none",
                "z-index": "10000000",
                "fontSize": "25px",
                "will-change": "transform"
            };

            // Init, and set properties
            this.init = function (x, y, color) {

                this.velocity = {
                    x: (Math.random() < 0.5 ? -1 : 1) * (Math.random() / 2),
                    y: 1
                };

                this.position = {x: x + 10, y: y + 10};
                this.initialStyles.color = color;

                this.element = document.createElement('span');
                this.element.innerHTML = this.character;
                applyProperties(this.element, this.initialStyles);
                this.update();

                document.querySelector('.js-cursor-container').appendChild(this.element);
            };

            this.update = function () {
                this.position.x += this.velocity.x;
                this.position.y += this.velocity.y;
                this.lifeSpan--;

                this.element.style.transform = "translate3d(" + this.position.x + "px," + this.position.y + "px, 0) scale(" + (this.lifeSpan / 120) + ")";
            }

            this.die = function () {
                this.element.parentNode.removeChild(this.element);
            }

        }

        /**
         * Utils
         */

        // Applies css `properties` to an element.
        function applyProperties(target, properties) {
            for (var key in properties) {
                target.style[key] = properties[key];
            }
        }

        if (!('ontouchstart' in window || navigator.msMaxTouchPoints)) init();
    })();
</script>


<span class="js-cursor-container">

<!--居中，已废弃-->
<center>

    <!--头部表格-->
    <table width="1452" border="0" cellpadding="0" cellspacing="0">
        <!--        标题-->
        <tr bgcolor="#8696a7" style="text-align:center;">
            <td>
                <img src="images/lou.png" style="width: 110px;height: 110px;text-align:center;">
            </td>
            <td colspan="9" height="10">
                <p style="color:#d8caaf;font-size: 70px;text-align:center;">
                    楼栋信息管理系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
            </td>
        </tr>

        <tr style="background-color: #965454">
            <td colspan="9" height="10">&nbsp;</td>
        </tr>

        <!--        信息-->
        <tr style="background-color: #965454">
            <td width="10%" align="center" valign="middle" style="font-size: 30px;"><b><?php echo date("Y-m-d"); ?></b>
            </td>
            <td width="10%" align="center" valign="middle"><a href="index.php"
                                                              style="font-size: 30px;color: black;text-decoration: none;">全部信息</a>
            </td>
            <td width="10%" align="center" valign="middle"><a href="add_building.php"
                                                              style="font-size: 30px;color: black;text-decoration: none;">添加信息</a>
            </td>
            <td width="15%" align="center" valign="middle"><a href="search1.php"
                                                              style="font-size: 30px;color: black;text-decoration: none;">查询楼号</a>
            </td>
            <td width="10%" align="center" valign="middle"><a href="building_update.php"
                                                              style="font-size: 30px;color: black;text-decoration: none;">信息修改</a>
            </td>
            <td width="10%" align="center" valign="middle"><a href="searchdel.php"
                                                              style="font-size: 30px;color: black;text-decoration: none;">信息删除</a>
            </td>
            <td width="10%" align="center" valign="middle"><a href="check_in.php"
                                                              style="font-size: 30px;color: black;text-decoration: none;">登录账号</a>
            </td>
        </tr>
        <tr style="background-color: #965454">
            <td colspan="9" height="10">&nbsp;</td>
        </tr>

        <!--        小标题-->
        <tr>
            <td colspan="9" height="10" style="color: #7b8b6f;text-align: center;">
                <h1>全部信息</h1>
            </td>
        </tr>
        <!--<tr>-->
        <!--    	<td  colspan="9" height="10" >&nbsp;</td>-->
        <!--    </tr>-->
    </table>

    <?php
            if ($_SESSION['type'] == 0) {
                echo '<font color ="#CC0000">请登录!</font>';
                exit();
            }
            ?>

    <!--中部表格-->
    <?php
    include_once("conn/conn.php");//包含数据库连接文件
    ?>
    <table width="1452" height="200" border="1" cellpadding="1" cellspacing="1" bordercolor="#656565"
           style="background-color: #fdf9ee">
        <tr>
            <td width="10%" align="center">楼栋序号</td>
            <td width="10%" align="center">楼栋编号</td>
            <td width="20%" align="center">楼栋名</td>
            <td width="10%" align="center">楼栋类型</td>
            <td width="10%" align="center">楼栋层数</td>
            <td width="15%" align="center">楼栋地址</td>
            <td width="10%" align="center">操作</td>
        </tr>
        <?php
        $pagesize = 10;                                    //每页显示记录数
        $sqlstr = "select * from building order by buildingId";//定义查询语句
        $total = mysqli_query($conn, $sqlstr);//执行查询语句
        $totalNum = mysqli_num_rows($total);                    //总记录数
        $pagecount = ceil($totalNum / $pagesize);                        //总页数
        (!isset($_GET['page'])) ? ($page = 1) : $page = $_GET['page'];                //当前显示页数
        ($page <= $pagecount) ? $page : ($page = $pagecount);//当前页大于总页数时把当前页定义为总页数
        $f_pageNum = $pagesize * ($page - 1);                                //当前页的第一条记录
        $sqlstr1 = $sqlstr . " limit " . $f_pageNum . "," . $pagesize;//定义SQL语句，通过limit关键字控制查询范围和数量
        $result = mysqli_query($conn, $sqlstr1);                                //执行查询语句
        while ($rows = mysqli_fetch_array($result)) {                                    //循环输出查询结果
            ?>
            <tr>
                <td width="10%" height="25" align="center"><?php echo $rows['buildingId']; ?></td>
                <td width="10%" align="center"><?php echo $rows['buildingNumber']; ?></td>
                <td width="20%" align="center"><?php echo $rows['buildingName']; ?></td>
                <td width="10%" align="center"><?php echo $rows['buildingType']; ?></td>
                <td width="10%" align="center"><?php echo $rows['buildingFloorNumber']; ?></td>
                <td width="15%" align="center"><?php echo $rows['buildingAddress']; ?></td>
                <td width="10%" align="center">

            <?php
            if ($_SESSION['type'] == 1) {
                echo "<a href=building_update.php?buildingid=" . $rows[0] . ">修改</a>/<a href=delete2.php?buildingId=" . $rows[0] . ">删除</a>";
//                echo '<font color ="#CC0000">管理员</font>';
            }else{
                echo '<font color ="#CC0000">非管理员，无权访问</font>';
            }
            ?>
                </td>
            </tr>
            <?php
        }
        ?>
        <tr>
            <td height="25" colspan="8" align="left">&nbsp;&nbsp;
                <?php
                echo "共" . $totalNum . "栋楼&nbsp;&nbsp;";
                echo "第" . $page . "页/共" . $pagecount . "页&nbsp;&nbsp;";
                if ($page != 1) {//如果当前页不是1则输出有链接的首页和上一页
                    echo "<a href='?page=1'>首页</a>&nbsp;";
                    echo "<a href='?page=" . ($page - 1) . "'>上一页</a>&nbsp;&nbsp;";
                } else {//否则输出没有链接的首页和上一页
                    echo "首页&nbsp;上一页&nbsp;&nbsp;";
                }
                if ($page != $pagecount) {//如果当前页不是最后一页则输出有链接的下一页和尾页
                    echo "<a href='?page=" . ($page + 1) . "'>下一页</a>&nbsp;";
                    echo "<a href='?page=" . $pagecount . "'>尾页</a>&nbsp;&nbsp;";
                } else {//否则输出没有链接的下一页和尾页
                    echo "下一页&nbsp;尾页&nbsp;&nbsp;";
                }
                ?>
            </td>
        </tr>
    </table>


    <!--尾部表格-->
    <table width="1452" border="0" cellpadding="0" cellspacing="0" style="background-color: #d3d4cc;text-align:center;">
        <tr>
            <td colspan="9" height="10">&nbsp;</td>
        </tr>
        <tr>
            <td>页面制作者：潘洪立</td>
        </tr>
        <tr>
            <td>学号：2006030217</td>
        </tr>
        <tr>
            <td>邮箱：1321556096@qq.com</td>
        </tr>
    </table>

</center>
    </span>
</body>
</html>
